function disableSubmit(finalResult, submitButtonId) {
	if (finalResult) {
		document.getElementById(submitButtonId).disabled = true;
		return finalResult;
	} else {
		return finalResult;
	}
}

//跳转页面
function jumpUserPage() {
	var pageValue = document.getElementById("jumpPageValue").value;
	simpleTable.togglePage(pageValue);
}

var formObj = null;
var formAction = null;
function batchDelete(action, checkboxName, form) {
	if (!hasOneChecked(checkboxName)) {
		// alert('请选择要操作的对象!');
		parent.showDialogAlert(message.mustSelectedObject());
		return;
	}
	formObj = form;
	formAction = action;
	parent.showDialogConfirm(message.confirmBatchDelete(),
			"contentFormSubmit()");
	/*
	if (confirm('确定执行[删除]操作?')){
	    form.action = action;
	    form.submit();
	}*/
}
//批量上线
function batchUp(action, checkboxName, form,optName) {
	if (!hasOneChecked(checkboxName)) {
		//alert('请选择要操作的对象!');
		parent.showDialogAlert(message.mustSelectedObject());
		return;
	}
	formObj = form;
	formAction = action;
	parent.showDialogConfirm(message.confirmBatchOpt(optName),
			"contentFormSubmit()");
}
//批量下线
function batchDown(action, checkboxName, form,optName) {
	if (!hasOneChecked(checkboxName)) {
		//alert('请选择要操作的对象!');
		parent.showDialogAlert(message.mustSelectedObject());
		return;
	}
	formObj = form;
	formAction = action;
	parent.showDialogConfirm(message.confirmBatchOpt(optName),
			"contentFormSubmit()");
}
//选择内容
function checkedItems(id) {
	document.getElementById("items_" + id).checked = true;
}

//批量改变状态
function batchStatus(action, checkboxName, form, optName) {
	if (!hasOneChecked(checkboxName)) {
		//alert('请选择要操作的对象!');
		parent.showDialogAlert(message.mustSelectedObject());
		return;
	}
	formObj = form;
	formAction = action;
	parent.showDialogConfirm(message.confirmBatchOpt(optName),
			"contentFormSubmit()");
	/*
	if (confirm('确定批量执行['+optName+']操作?')){
	    form.action = action;
	    form.submit();
	}*/
}

//指添加内容
function batchAddContent(action, checkboxName, form, optName) {
	if (!hasOneChecked(checkboxName)) {
		//alert('请选择要操作的对象!');
		parent.parent.showDialogAlert(message.mustSelectedObject());
		return;
	}
	closeIframeRefreshConetnt();
	formObj = form;
	formAction = action;
	parent.parent.showDialogIframeConfirm(message.confirmBatchOpt(optName),
			"contentFormSubmit()");
	/*
	if (confirm('确定批量执行['+optName+']操作?')){
	    form.action = action;
	    form.submit();
	}*/
}

//改变状态
function changeStatusPrompt(actionUrl, optName, type, keyName) {
	var msg = message.confirmOpt(optName, type, keyName);
	parent.showDialogConfirm(msg, "redirectPage('" + actionUrl + "')");
}

//改变状态提交查询条件
function changeStatusGetSearch(action, form, optName, type, keyName) {
	formObj = form;
	formAction = action;
	var msg = message.confirmOpt(optName, type, keyName);
	parent.showDialogConfirm(msg, "contentFormSubmit()");
}

//数据页面返回
var formId = null;
function dataPageBack(formIds, actionUrl) {
	var msg = message.confirmPageLeave();
	//msg = "您是否保存当前操作？";
	formId = formIds;
	parent.showDialogConfirm(msg, "redirectPage('" + actionUrl + "')"); //离开提示
	// parent.showDialogBackConfirm(msg,"dataFormeSubmit()","redirectPage('"+actionUrl+"')"); //保存提示
}

//数据form提交
function dataFormeSubmit() {
	$("#" + formId).get(0).submit();
}

//内容提交
function contentFormSubmit() {
	if (formAction != null) {
		formObj.action = formAction;
		formObj.submit();
	}
}

//forme 提交
function formeSubmit(id) {
	var form = $("#" + id);
	var isCanSubmit = true;
	form.find("input[type!='hidden']").each(
					function() {
						var type = $(this).attr("type");
						if (type == "text")
							$(this).val($.trim($(this).val()));
						var dataType = $(this).attr("alt");
						var value = $(this).val();
						var title = $(this).parent().parent().find(".label").html();
						var datasrc = $(this).attr("datasrc");
						if (dataType != undefined && dataType.length > 0
								&& datasrc != "true") {
							if (title.indexOf('<') != -1) {
								title = title.substring(0, title.indexOf('<'));
							}
							if ($.trim(value).length < 1) {
								alert(title + message.alertNotNull());
								isCanSubmit = false;
								return false; //跳出循环  
							} else {
								if (dataType == "java.lang.Integer"
										&& isNaN(value)) {
									alert(title + message.alertMustNumber());
									isCanSubmit = false;
									return false; //跳出循环  
								} else if (dataType == "java.util.Date") {
									//年月日时分秒正则表达式
									var r = value
											.match(/^(\d{1,4})\-(\d{1,2})\-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/);
									if (r == null) {
										alert(title + message.alertDateFormat());
										isCanSubmit = false;
										return false; //跳出循环  
									}
								} else if (dataType == "java.lang.LoginName") {
									if (value == "") {
										alert(title + message.alertNotNull());
										isCanSubmit = false;
										return false;
									} else if (value.length < 6) {
										alert(title+ messageVar.alertLoginNameMustGreaterThanSix);
										isCanSubmit = false;
										return false;
									}
								} else if (dataType == "dmobile") {
									if ($.trim(value).length < 1) {
										alert(title + message.alertNotNull());
										isCanSubmit = false;
										return false;
									} else if ($.trim(value).search(
											/^(13|15|18)[0-9]{9}$/) == -1) {
										isCanSubmit = false;
										alert(title + message.alertFomatError());
										return false;
									}
								} else if (dataType == "dpassword") {
									if ($.trim(value) == "") {
										isCanSubmit = false;
										alert(message.alertPasswordNotNull());
									} else if ($.trim(value).length < 6) {
										isCanSubmit = false;
										alert(message
												.alertPasswordMustGreaterThanSix());
									} else if ($.trim(value).length > 12) {
										isCanSubmit = false;
										alert(title	+ message.alertPasswordMustLessThanTwelve());
									} else if ($.trim(value).search(/\\w+$/) == null) {
										isCanSubmit = false;
										alert(title+ message.alertPasswordMustFormat());
									}else if (dataType == "url") {
										if ($.trim(value).search(/^www.[0-9a-zA-z]+.(com|net|cn)$/) == -1) {
										isCanSubmit = false;
										alert(title + message.alertFomatError());
										}
									}
								}
							}
						} else if (value != "" && dataType != undefined
								&& dataType.length > 0 && datasrc == "true") {
							if (title.indexOf('<') != -1) {
								title = title.substring(0, title.indexOf('<'));
							}
							if (dataType == "demail") {
								if (value
										.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1) {
									isCanSubmit = false;
									alert(title + message.alertFomatError());
								}
							} else if (dataType == "dphone") {
								if ($
										.trim(value)
										.search(
												/^(([0\+]\d{2,3}-)?(0\d{2,3})-)?(\d{7,8})(-(\d{3,}))?$/) == -1) {
									isCanSubmit = false;
									alert(title + message.alertFomatError());
								}
							} else if (dataType == "dmobile") {
								if ($.trim(value)
										.search(/^(13|15|18)[0-9]{9}$/) == -1) {
									isCanSubmit = false;
									alert(title + message.alertFomatError());
								}
							} else if (dataType == "dfax") {
								if ($
										.trim(value)
										.search(
												/^(([0\\+]\\d{2,3}-)?(0\\d{2,3})-)?(\\d{7,8})(-(\\d{3,}))?$/) == -1) {
									isCanSubmit = false;
									alert(title + message.alertFomatError());
								}
							} else if (dataType == "dlottery") {
								if (isNaN(value)) {
									isCanSubmit = false;
									alert(title + message.alertFomatError());
								}
							} else if (dataType == "zipcode") {
								if ($.trim(value).search(/^\\d{6}$/) == -1) {
									isCanSubmit = false;
									alert(title + message.alertFomatError());
								}
							}
						}
					});
	if (isCanSubmit)
		form.get(0).submit();
	//alert("可以提交");
}

function hasOneChecked(name) {
	var items = document.getElementsByName(name);
	if (items.length > 0) {
		for ( var i = 0; i < items.length; i++) {
			if (items[i].checked == true) {
				return true;
			}
		}
	} else {
		if (items.checked == true) {
			return true;
		}
	}
	return false;
}

function hasOneCanUp(name){
    var items = document.getElementsByName(name);
    if (items.length > 0) {
        for (var i = 0; i < items.length; i++){
            if (items[i].checked == true){
            	var chkvalue= items[i].value.split("_");
            	var chkstatus=chkvalue[1];
                if(chkstatus!=1){
                	return false;
                }
            }
        }
    }
    return true;
}

function hasOneCanDown(name){
    var items = document.getElementsByName(name);
    if (items.length > 0) {
        for (var i = 0; i < items.length; i++){
            if (items[i].checked == true){
            	var chkvalue= items[i].value.split("_");
            	var chkstatus=chkvalue[1];
                if(chkstatus!=6){
                	return false;
                }
            }
        }
    }
    return true;
}

function setAllCheckboxState(name,state) {
	var elms = document.getElementsByName(name);
	for(var i = 0; i < elms.length; i++) {
		elms[i].checked = state;
	}
}

function getReferenceForm(elm) {
	while(elm && elm.tagName != 'BODY') {
		if(elm.tagName == 'FORM') return elm;
		elm = elm.parentNode;
	}
	return null;
}

function selectOneOrmore(action,checkboxName,form){
	if (!hasOneChecked(checkboxName)){
            return "";
    }
   var tmpvalue=getSelectedValue(checkboxName);
   return tmpvalue;
}
var tmpvalue="";
function getSelectedValue(name){
    var items = document.getElementsByName(name);
    if (items.length > 0) {
        for (var i = 0; i < items.length; i++){
            if (items[i].checked == true){
            	tmpvalue+=items[i].value+";";
            }
        }
         return tmpvalue;
    } else {
        if (items.checked == true) {
            return tmpvalue;
        }
    }
    return "";
}
function changeContents(value){
	hideDialog("dialogIframes");
	contentFrame.window.changeContents(value);
}